/*
 * CorfimacionEliminar.java
 *
 * Created on 17 de mayo de 2006, 05:25 PM
 */

package ig.metrica.ui.seguridad;

import ig.util.NoContinuaException;

/**
 *
 * @author  jsanchez
 */
public class CorfimacionEliminar extends javax.swing.JDialog {
    MUsuarios modelo=null;
    /** Creates new form CorfimacionEliminar */
    public CorfimacionEliminar(java.awt.Frame parent, boolean modal,MUsuarios modelo) {        
        super(parent,"Confirmar para eliminar", modal);
        this.modelo=modelo;
        initComponents();
        java.awt.Dimension dimensionScreen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Rectangle dimensionPantalla = getBounds();
        setLocation((dimensionScreen.width - dimensionPantalla.width) / 2, (dimensionScreen.height - dimensionPantalla.height) / 2);        
        this.setVisible(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        usuario = new javax.swing.JRadioButton();
        cuenta = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        Aceptar = new javax.swing.JButton();
        Cancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel1.setText("Que desea Eliminar");

        buttonGroup1.add(usuario);
        usuario.setFont(new java.awt.Font("Dialog", 0, 12));
        usuario.setText("Usuario, Esta opcion elimina un usuario, y cada una de sus cuentas");
        usuario.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        usuario.setMargin(new java.awt.Insets(0, 0, 0, 0));

        buttonGroup1.add(cuenta);
        cuenta.setFont(new java.awt.Font("Dialog", 0, 12));
        cuenta.setSelected(true);
        cuenta.setText("Cuenta, Elimina una cuenta de un usuario especifico");
        cuenta.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        cuenta.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jLabel2.setIcon(new javax.swing.ImageIcon("lib/images/borrar.gif"));

        Aceptar.setText("Aceptar");
        Aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AceptarActionPerformed(evt);
            }
        });

        Cancelar.setText("Cancelar");
        Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(usuario, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .add(cuenta, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .add(layout.createSequentialGroup()
                                .add(137, 137, 137)
                                .add(Aceptar)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(Cancelar)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jLabel1)
                        .add(137, 137, 137)))
                .add(jLabel2)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jLabel1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(usuario)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(cuenta)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(Cancelar)
                            .add(Aceptar))))
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        try {
            modelo.cancelar();
            this.dispose();
        } catch (NoContinuaException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_formWindowClosing

    private void CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarActionPerformed
        try {
            modelo.cancelar();
            this.dispose();
        } catch (NoContinuaException ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_CancelarActionPerformed

    private void AceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AceptarActionPerformed
        if(this.cuenta.isSelected())
            modelo.setOpcionEliminar("cuenta");
        else if(this.usuario.isSelected())
            modelo.setOpcionEliminar("usuario");
        this.dispose();
    }//GEN-LAST:event_AceptarActionPerformed
    
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new CorfimacionEliminar(new javax.swing.JFrame(), true).setVisible(true);
//            }
//        });
//    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Aceptar;
    private javax.swing.JButton Cancelar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton cuenta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JRadioButton usuario;
    // End of variables declaration//GEN-END:variables
    
}
